<template>
  <div>
    <el-table
      :data="pi.records"
      :stripe="true"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="学号">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名">
      </el-table-column>
      <el-table-column
        label="职务">
        <template slot-scope="scope">
          <div v-if="scope.row.job==1">班长</div>
          <div v-if="scope.row.job==2">组长</div>
          <div v-if="scope.row.job==3">学员</div>
        </template>
      </el-table-column>

      <el-table-column
        label="专业">
        <template slot-scope="scope">
          <div v-if="scope.row.major==1">金融</div>
          <div v-if="scope.row.major==2">计算机</div>
          <div v-if="scope.row.major==3">会计</div>
        </template>
      </el-table-column>
      <el-table-column
        prop="grade"
        label="班级">
      </el-table-column>
      <el-table-column
        label="性别">
        <template slot-scope="scope">
          {{scope.row.sex==0?"女":"男"}}
        </template>
      </el-table-column>
      <el-table-column
        prop="birthday"
        label="生日">
      </el-table-column>
      <el-table-column
        prop="tel"
        label="电话">
      </el-table-column>

      <el-table-column
        label="操作">
        <template slot-scope="scope">
          <router-link :to="{path:'/manager/stu/rec',query:{stuId:scope.row.id,stuName:scope.row.name}}"><el-button>查看</el-button></router-link>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      layout="sizes, prev, pager, next, jumper, ->, total"
      :total="pi.total"
      :page-size.sync="pi.size"
      :page-sizes="[2,5,10,50]"
      :current-page.sync="pi.current"
      :pager-count="9"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      background>
    </el-pagination>
    <router-view/>
  </div>
</template>

<script>
    export default {
        name: "stuList",
      data(){
          return {
            pi:{}
          }
      },
      created(){
        //发出ajax请求请求后端代码
        this.selectByPage(1,5);
      },
      methods:{
        handleSizeChange(size){
          //再次调用ajax到后台取数据
          this.selectByPage(this.pi.current,size);
        },
        handleCurrentChange(page){
          this.selectByPage(page,this.pi.size);
        },
        selectByPage(pageNum,pageSize){
          this.axios.get("/student/selectByPage/"+pageNum+"/"+pageSize).then((resp)=>{
            this.pi=resp.data;
          });
        }
      }
    }
</script>

<style scoped>

</style>
